//AC
//http://poj.org/problem?id=1002
//

#include <stdlib.h>
#include<stdio.h>
#include <string.h>

int arrayNode[100001];
int arrayIndex = 0;

int outputNumber = 0;

void SaveToArray(int num[8]);
int Parent(int i);
int Left(int i);
int Right(int i);
int HeapSize();
void MinHeapify(int op_array[],int i);
void exchange(int *a,int *b);
void Build_Min_Heap(int op_array[]);
void output(int currentNode,int time);
void checkOutput();

int main() 
{ 

#ifdef FILEIO
  freopen("in.txt","r",stdin); 
  freopen("out.txt","w",stdout); 
#endif

  int n;
  char temp[50];
  int num[8];
  int map[] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9,0};
  int i,j,k;

  scanf("%d\n",&n);

  while(n-- > 0)   
    {
      memset(temp,0,50);
      memset(num,0,8*sizeof(int));
      j = 0;
      scanf("%s",temp);
      for(i = 0;i<50 && temp[i] != '\0';i++)
        {
          if(temp[i] >= 'A' && temp[i] <= 'Z')
            {
              if(temp[i] == 'Q'||temp[i] == 'Z')
                continue;
              else
                {
                  num[j++] = map[temp[i] - 'A'];
                }
            }
          else if(temp[i] >= '0' && temp[i] <= '9')
            {
              num[j++] = temp[i] - '0';
            }
          else if(temp[i] == '-')
              continue;
          else
            continue;
        }
      SaveToArray(num);
      //printf("%d\n",arrayNode[arrayIndex - 1]);
  
    }

  Build_Min_Heap(arrayNode);

  int currentNode = arrayNode[0];
  int time = 1;
  for(i=HeapSize()-1;i>=1;i--)
    {
      exchange(&arrayNode[0],&arrayNode[i]);
      arrayIndex--;
      MinHeapify(arrayNode,0);
      if(currentNode == arrayNode[0]) 
        {
          time++;
        }
      else
        {
          output(currentNode,time);
          currentNode = arrayNode[0];
          time = 1;
        }
    }

  output(currentNode,time);
  checkOutput();

#ifdef FILEIO
  fclose(stdin);
  fclose(stdout);
#endif
  
  return 0; 
}

void checkOutput()
{
  if(outputNumber == 0) 
    {
      printf("No duplicates.\n");
    }
}

void output(int currentNode,int time)
{
  char outputArray[9] = {0};
  memset(outputArray,'0',3*sizeof(char));
  outputArray[3]='-';
  memset(outputArray+4,'0',4*sizeof(char));
  int i = 7;
  if(time>1)
    {
      outputNumber++;
      while(currentNode > 0)
        {
          if(i==3)
            {
              outputArray[i] = '-';
            }
          else
            {
              outputArray[i] = currentNode%10 + '0';
              currentNode = currentNode/10;
            }
		  i--;
        }
      printf("%s %d\n",outputArray,time);
    }
}

void SaveToArray(int num[8])
{
  int i = 0;
  int index = 1;
  int *p = &(arrayNode[arrayIndex++]);

  for(i = 6;i >= 0;i--)
    {
      *p += num[i]*index;
      index *= 10;
    }
}

int Parent(int i)
{
  if(i==0)
    return 0;
  return (i+1)/2 - 1;
}

int Left(int i)
{
  return 2*(i+1) - 1;
}

int Right(int i)
{
  return 2*(i+1);
}

int HeapSize()
{
  return arrayIndex;
}


void exchange(int *a,int *b)
{
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

void MinHeapify(int op_array[],int i)
{
  int l = Left(i);
  int r = Right(i);

  int smallest=i;

  if(l<HeapSize() && op_array[l]<op_array[i])
    smallest = l;

  if(r<HeapSize()&& op_array[r]<op_array[smallest])
    smallest = r;

  if(smallest!=i)
    {
      exchange(&op_array[i],&op_array[smallest]);
      MinHeapify(op_array,smallest);
    }
}

void Build_Min_Heap(int op_array[])
{
  int i=0;
  for(i=HeapSize()/2-1;i>=0;i--)
    MinHeapify(op_array,i);
}
